from PyQt4 import QtCore, QtGui;

class ToolbarCmds(QtCore.QObject):
    def __init__(self, parentWin, actionCmds):
        super(ToolbarCmds, self).__init__();
        self.parentWin = parentWin;
        self.actionCmds = actionCmds;
        self.createToolbarCmds();
        self.bToolBarVisible = True;
    
    def createToolbarCmds(self):
        self.toolBarFile = QtGui.QToolBar("File");
        self.toolBarEdit = QtGui.QToolBar("Edit");
        self.toolBarView = QtGui.QToolBar("View");
        self.toolBarGraph = QtGui.QToolBar("Graph");
        self.toolBarData = QtGui.QToolBar("Data");
#         self.toolBarBkgClr = QtGui.QToolBar("Background Color");
        self.parentWin.mainWin.addToolBar(self.toolBarFile);
        self.parentWin.mainWin.addToolBar(self.toolBarEdit);
        self.parentWin.mainWin.addToolBar(self.toolBarView);
        self.parentWin.mainWin.addToolBar(self.toolBarGraph);
        self.parentWin.mainWin.addToolBar(self.toolBarData);
#         self.parentWin.mainWin.addToolBar(self.toolBarBkgClr);
        
        #File Actions
        self.toolBarFile.addAction(self.actionCmds.actionNewGraph);
#        self.toolBarFile.addSeparator();
#        self.toolBarFile.addAction(self.actionCmds.actionLoadProject);
        self.toolBarFile.addAction(self.actionCmds.actionLoadGraph);
#        self.toolBarFile.addSeparator();
#        self.toolBarFile.addAction(self.actionCmds.actionSaveProject);
        self.toolBarFile.addAction(self.actionCmds.actionSaveGraph);
        
        #Edit Actions
        self.toolBarEdit.addAction(self.actionCmds.actionUndo);
        self.toolBarEdit.addAction(self.actionCmds.actionRedo);
        self.toolBarEdit.addSeparator();
        self.toolBarEdit.addAction(self.actionCmds.actionDelete);
        
        #View Actions
        self.toolBarView.addAction(self.actionCmds.actionFullScreen);
        self.toolBarView.addSeparator();
        self.toolBarView.addAction(self.actionCmds.actionZoomIn);
        self.toolBarView.addAction(self.actionCmds.actionZoomOut);
        self.toolBarView.addAction(self.actionCmds.actionZoomReset);
        
        #Graph Actions
        self.toolBarGraph.addAction(self.actionCmds.actionLayoutCurve);
        self.toolBarGraph.addAction(self.actionCmds.actionLayoutCircle);
        self.toolBarGraph.addAction(self.actionCmds.actionLayoutGrid);
        self.toolBarGraph.addAction(self.actionCmds.actionLayoutFlow);
        self.toolBarGraph.addSeparator();
        self.toolBarGraph.addAction(self.actionCmds.actionAnimateTrans);
        
        #Data Actions
        self.toolBarData.addAction(self.actionCmds.actionBuildGraph);
        self.toolBarData.addAction(self.actionCmds.actionGenerateTables);
        
        #Background Color Actions
#         self.toolBarBkgClr.addAction(self.actionCmds.actionStBkgColor_None);
#         self.toolBarBkgClr.addAction(self.actionCmds.actionStBkgColor_ByVal);
#         self.toolBarBkgClr.addAction(self.actionCmds.actionStBkgColor_ByR);
#         self.toolBarBkgClr.addAction(self.actionCmds.actionStBkgColor_ByD);
#         self.toolBarBkgClr.addSeparator();
#         self.toolBarBkgClr.addAction(self.actionCmds.actionActBkgColor_None);
#         self.toolBarBkgClr.addAction(self.actionCmds.actionActBkgColor_ByQ);
#         self.toolBarBkgClr.addAction(self.actionCmds.actionActPolicy);
#         self.toolBarBkgClr.addSeparator();
#         self.toolBarBkgClr.addAction(self.actionCmds.actionActShowNormalProbs);
#         self.toolBarBkgClr.addAction(self.actionCmds.actionActShowMaxProbs);
        
    def showToolBar(self):
        bVisible = False;
        self.bToolBarVisible = not self.bToolBarVisible;
        if self.bToolBarVisible:
            bVisible = True;
        else:
            bVisible = False;            
        self.toolBarFile.setVisible(bVisible);
        self.toolBarEdit.setVisible(bVisible);
        self.toolBarView.setVisible(bVisible);
        self.toolBarGraph.setVisible(bVisible);
        self.toolBarData.setVisible(bVisible);
#         self.toolBarBkgClr.setVisible(bVisible);
